<template>
  <div class="info-container">
    <div class="info-header">
      <h3 class="info-title">{{ title }}</h3>
    </div>
    <div class="info-content">
      <div v-for="(item, index) in items" :key="index" class="info-item">
        <div class="info-date">{{ item.date }}</div>
        <div class="info-text">
          <a @click="render_zixun_text(item)" target="_blank" class="info-link">{{ item.title }}</a>
          <p class="info-summary">{{ item.summary }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
const Router=useRouter()
const props = defineProps({
  title: {
    type: String,
    default: '资讯'
  },
  items: {
    type: Array,
    default: () => [
      {
        date: '06-01',
        title: '示例标题',
        summary: '这里是内容的简要描述',
        id: 1
      }
    ]
  }
})

const render_zixun_text = (data) => { 
  // 将主页的渲染文本进行共用。主页仅作简单的展示处理。
   const nav_to=Router.resolve({ name: 'community_render_index_rec_text', query: { id: data.id } });
   window.open(nav_to.href, '_blank');
}
onMounted(() => { 

})

</script>

<style scoped>
.info-container {
  width: 100%;
  height: auto;

  margin-left: 10px;
  margin-right: 10px;
  border: 1px solid #eaeaea;
  border-radius: 4px;
  font-family: 'Microsoft YaHei', Arial, sans-serif;
  overflow: hidden;
}

.info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #eaeaea;
}

.info-title {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.info-content {
  padding: 10px 20px;
  height: calc(100% - 50px);
  overflow-y: auto;
}

.info-item {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px dashed #eee;
}

.info-date {
  width: 50px;
  color: #888;
  font-size: 14px;
}

.info-text {
  flex: 1;
}

.info-link {
  color: #333;
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
  display: block;
  margin-bottom: 6px;
}

.info-link:hover {
  color: #50e3c2;
}

.info-summary {
  margin: 0;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}
</style>